package com.hyfrogx.modules.manage.controller.course;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.hyfrogx.common.utils.QueryExt;
import com.hyfrogx.common.utils.R;
import com.hyfrogx.modules.manage.controller.BaseController;
import com.hyfrogx.modules.manage.entity.course.CourseOrderCountEntity;

import com.hyfrogx.modules.manage.entity.course.CourseOrderEntity;
import com.hyfrogx.modules.manage.service.course.CourseOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;
/**
 * @author 罗春杰-技术部
 */
@RestController
@RequestMapping(value="CourseManageOrder")
@Api(value = "CourseManageOrderController",tags = {"后台-订单管理控制类"})
@Slf4j
public class CourseManageOrderController extends BaseController {
    @Autowired
    private CourseOrderService orderService;

    @RequestMapping(value="getallInCourseOrderList",method= RequestMethod.GET)
    @ApiOperation("订单详情")
    public R getallInCourseOrderList(@RequestParam Map map)
    {
        try {
            //获取订单统计,并把参数传给page，进行返回数据
            CourseOrderCountEntity hyc = orderService.getCourseOrderCount();

            int count = orderService.count(new QueryWrapper<CourseOrderEntity>().eq("status", 1).or().eq("status",null));
            hyc.setCperson(count);
            //通过前端参数查询符合条件的所有订单
            Page page =orderService.selectCourseOrderList(new QueryExt(map));
            return R.ok().put("data",page).put("count",hyc);
        } catch (Exception e) {
            log.info(e.getMessage());
            return R.error(e.getMessage());
        }
    }
}
